/*
    Dao FLTK2
    Copyright (C) 2010 Belousov Oleg <belousov.oleg@gmail.com>

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

#include <fltk/DoubleBufferWindow.h>
#include <dao.h>

#include "widget.h"
#include "group.h"
#include "window.h"

static void window_new(DaoContext *ctx, DValue *p[], int N) {
    int w = (int) p[0]->v.i;
    int h = (int) p[1]->v.i;
    char *title= (char*) DString_GetMBS(p[2]->v.s);

    fltk::DoubleBufferWindow *ptr;

    ptr = new fltk::DoubleBufferWindow(w, h);
    ptr->copy_label(title);

    DaoCData *cdata = DaoContext_PutCData(ctx, ptr, &windowTyper);

    init_callback(ptr, cdata);
};

//

static DaoFuncItem windowMeth[] = {
    { window_new, "fltk_window(w:int, h:int, title:string)" },
    { NULL, NULL }
};

DaoTypeBase windowTyper = {
    "fltk_window",
    NULL,
    NULL,                       /* no constant number */
    windowMeth,                 /* methods */
    { &groupTyper, NULL },      /* parent type */
    { NULL },
    NULL,
    NULL                        /* free by free() */
};
